package com.luhuiguo.cms.server.handler;

import org.springframework.stereotype.Component;

import com.luhuiguo.cms.server.cache.Caches;
import com.luhuiguo.cms.server.web.filter.CachingFilter;
import com.luhuiguo.cms.shared.rpc.ClearCache;
import com.luhuiguo.cms.shared.rpc.ClearCacheResult;
import com.luhuiguo.gwt.dispatcher.server.ActionHandler;
import com.luhuiguo.gwt.dispatcher.server.ExecutionContext;
import com.luhuiguo.gwt.dispatcher.shared.exception.ActionException;

@Component
public class ClearCacheHandler implements ActionHandler<ClearCache, ClearCacheResult> {

    @Override
    public ClearCacheResult execute(ClearCache action, ExecutionContext context) throws ActionException {
        Caches.getCache(CachingFilter.CACHE_NAME).clear();
        return new ClearCacheResult();

    }

    @Override
    public Class<ClearCache> getActionType() {
        return ClearCache.class;
    }

    @Override
    public void rollback(ClearCache action, ClearCacheResult result, ExecutionContext context) throws ActionException {

    }

}
